package io.bdmc.modules.bss.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import io.bdmc.common.annotation.SysLogger;
import io.bdmc.common.utils.MyPage;
import io.bdmc.common.utils.R;
import io.bdmc.modules.bss.entity.DeviceMachineOsw;
import io.bdmc.modules.bss.model.DeviceMachineOswParam;
import io.bdmc.modules.bss.service.IDeviceMachineOswService;
import io.bdmc.modules.sys.controller.AbstractController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 黄露
 * @since 2021-05-28
 */

// "", description = "")
@RestController
@RequestMapping("/bss/deviceMachineOsw")
public class DeviceMachineOswController extends AbstractController {

	@Autowired
	IDeviceMachineOswService _devicemachineoswSvs;

	@GetMapping("/list")
	// "分页查询", notes = "分页查询")
	@RequiresPermissions("bss:deviceMachineOsw:list")
	public R list(DeviceMachineOswParam params) {
		MyPage<DeviceMachineOsw> myPage = new MyPage<DeviceMachineOsw>(params.getCurrent(), params.getSize());
		myPage = _devicemachineoswSvs.mySelectPage(myPage);
		return R.ok().putPageData(myPage.getRecords(), myPage.getTotal());

	}

	@SysLogger("修改")
	@PostMapping("/update")
	// "修改", notes = "修改")
	@RequiresPermissions("bss:deviceMachineOsw:update")
	public R update(@RequestBody DeviceMachineOsw devicemachineosw) {
		Boolean b = devicemachineosw.updateById();
		return R.trueOrFalse(b);
	}

	@SysLogger("删除")
	@DeleteMapping("/delete/{machineOswId}")
	// "删除", notes = "删除")
	@RequiresPermissions("bss:deviceMachineOsw:delete")
	public R delete(@PathVariable Integer machineOswId) {
		if (machineOswId > 0)
			_devicemachineoswSvs.removeById(machineOswId);
		return R.ok();
	}
}
